#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
乘方和开方运算示例
"""

from mcp.client.stdio import stdio_client
import asyncio

async def main():
    # 连接MCP服务
    client = await stdio_client()
    
    # 调用乘方运算
    result = await client.call_tool("power", {"base": 2, "exponent": 3})
    print(f"2的3次方: {result}")
    
    # 调用开方运算
    result = await client.call_tool("square_root", {"x": 9})
    print(f"9的平方根: {result}")
    
    # 测试异常情况
    try:
        await client.call_tool("square_root", {"x": -4})
    except Exception as e:
        print(f"-4的平方根错误: {str(e)}")

if __name__ == "__main__":
    asyncio.run(main())